<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>EOS.IO: Memory C API</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="eos-logo.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">EOS.IO
   &#160;<span id="projectnumber">DAWN3.0.1</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">Memory C API<div class="ingroups"><a class="el" href="group__contractdev.html">Smart Contract API Reference</a> &raquo; <a class="el" href="group__memoryapi.html">Memory API</a></div></div>  </div>
</div><!--header-->
<div class="contents">

<p>Defines common memory functions.  
<a href="#details">More...</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ga87ed00a8f774a9d36d650b80a36ad932"><td class="memItemLeft" align="right" valign="top">void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__memorycapi.html#ga87ed00a8f774a9d36d650b80a36ad932">sbrk</a> (<a class="el" href="group__types.html#ga06896e8c53f721507066c079052171f8">uint32_t</a> num_bytes)</td></tr>
<tr class="memdesc:ga87ed00a8f774a9d36d650b80a36ad932"><td class="mdescLeft">&#160;</td><td class="mdescRight">Allocate page memory.  <a href="#ga87ed00a8f774a9d36d650b80a36ad932">More...</a><br /></td></tr>
<tr class="separator:ga87ed00a8f774a9d36d650b80a36ad932"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga59ed1449718a3c27f7622cb3efb845af"><td class="memItemLeft" align="right" valign="top">void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__memorycapi.html#ga59ed1449718a3c27f7622cb3efb845af">memcpy</a> (void *destination, const void *source, <a class="el" href="group__types.html#ga06896e8c53f721507066c079052171f8">uint32_t</a> num)</td></tr>
<tr class="memdesc:ga59ed1449718a3c27f7622cb3efb845af"><td class="mdescLeft">&#160;</td><td class="mdescRight">Copy a block of memory from source to destination.  <a href="#ga59ed1449718a3c27f7622cb3efb845af">More...</a><br /></td></tr>
<tr class="separator:ga59ed1449718a3c27f7622cb3efb845af"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga174f86fdde222a278e5524a8aea63da9"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__types.html#ga0d2e949ab6a1bb62f1b295cc79bc1f60">int32_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__memorycapi.html#ga174f86fdde222a278e5524a8aea63da9">memcmp</a> (void *ptr1, const void *ptr2, <a class="el" href="group__types.html#ga06896e8c53f721507066c079052171f8">uint32_t</a> num)</td></tr>
<tr class="memdesc:ga174f86fdde222a278e5524a8aea63da9"><td class="mdescLeft">&#160;</td><td class="mdescRight">Copy a block of memory from source to destination.  <a href="#ga174f86fdde222a278e5524a8aea63da9">More...</a><br /></td></tr>
<tr class="separator:ga174f86fdde222a278e5524a8aea63da9"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gad8eef9133e11fe77cd34792771f81761"><td class="memItemLeft" align="right" valign="top">void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__memorycapi.html#gad8eef9133e11fe77cd34792771f81761">memset</a> (void *ptr, <a class="el" href="group__types.html#ga06896e8c53f721507066c079052171f8">uint32_t</a> value, <a class="el" href="group__types.html#ga06896e8c53f721507066c079052171f8">uint32_t</a> num)</td></tr>
<tr class="memdesc:gad8eef9133e11fe77cd34792771f81761"><td class="mdescLeft">&#160;</td><td class="mdescRight">Fill a block of memory with the provided value.  <a href="#gad8eef9133e11fe77cd34792771f81761">More...</a><br /></td></tr>
<tr class="separator:gad8eef9133e11fe77cd34792771f81761"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<h2 class="groupheader">Function Documentation</h2>
<a id="ga174f86fdde222a278e5524a8aea63da9"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga174f86fdde222a278e5524a8aea63da9">&#9670;&nbsp;</a></span>memcmp()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__types.html#ga0d2e949ab6a1bb62f1b295cc79bc1f60">int32_t</a> memcmp </td>
          <td>(</td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>ptr1</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const void *&#160;</td>
          <td class="paramname"><em>ptr2</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__types.html#ga06896e8c53f721507066c079052171f8">uint32_t</a>&#160;</td>
          <td class="paramname"><em>num</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Compare block of memory from source to destination. </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">ptr1</td><td>Pointer to first data to compare </td></tr>
    <tr><td class="paramname">ptr2</td><td>Pointer to second data to compare </td></tr>
    <tr><td class="paramname">num</td><td>Number of bytes to compare.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>the destination pointer </dd></dl>

</div>
</div>
<a id="ga59ed1449718a3c27f7622cb3efb845af"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga59ed1449718a3c27f7622cb3efb845af">&#9670;&nbsp;</a></span>memcpy()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void* memcpy </td>
          <td>(</td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>destination</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const void *&#160;</td>
          <td class="paramname"><em>source</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__types.html#ga06896e8c53f721507066c079052171f8">uint32_t</a>&#160;</td>
          <td class="paramname"><em>num</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Copy a block of memory from source to destination. </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">destination</td><td>Pointer to the destination to copy to. </td></tr>
    <tr><td class="paramname">source</td><td>Pointer to the source for copy from. </td></tr>
    <tr><td class="paramname">num</td><td>Number of bytes to copy.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>the destination pointer</dd></dl>
<p>Example: </p><div class="fragment"><div class="line"><span class="keywordtype">char</span> dest[6] = { 0 };</div><div class="line"><span class="keywordtype">char</span> source[6] = { <span class="charliteral">&#39;H&#39;</span>, <span class="charliteral">&#39;e&#39;</span>, <span class="charliteral">&#39;l&#39;</span>, <span class="charliteral">&#39;l&#39;</span>, <span class="charliteral">&#39;o&#39;</span>, <span class="charliteral">&#39;\0&#39;</span> };</div><div class="line"><a class="code" href="group__memorycapi.html#ga59ed1449718a3c27f7622cb3efb845af">memcpy</a>(dest, source, 6 * <span class="keyword">sizeof</span>(<span class="keywordtype">char</span>));</div><div class="line"><a class="code" href="group__consolecapi.html#gaa99be0cc1b9e5cbbc2b12a43537e7ed3">prints</a>(dest); <span class="comment">// Output: Hello</span></div></div><!-- fragment --> 
</div>
</div>
<a id="gad8eef9133e11fe77cd34792771f81761"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gad8eef9133e11fe77cd34792771f81761">&#9670;&nbsp;</a></span>memset()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void* memset </td>
          <td>(</td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>ptr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__types.html#ga06896e8c53f721507066c079052171f8">uint32_t</a>&#160;</td>
          <td class="paramname"><em>value</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__types.html#ga06896e8c53f721507066c079052171f8">uint32_t</a>&#160;</td>
          <td class="paramname"><em>num</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Fill block of memory. </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">ptr</td><td>Pointer to memory to fill. </td></tr>
    <tr><td class="paramname">value</td><td>Value to set (it is passed as an int but converted to unsigned char). </td></tr>
    <tr><td class="paramname">num</td><td>Number of bytes to be set to the value.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>the destination pointer</dd></dl>
<p>Example: </p><div class="fragment"><div class="line"><span class="keywordtype">char</span> ptr[6] = { <span class="charliteral">&#39;H&#39;</span>, <span class="charliteral">&#39;e&#39;</span>, <span class="charliteral">&#39;l&#39;</span>, <span class="charliteral">&#39;l&#39;</span>, <span class="charliteral">&#39;o&#39;</span>, <span class="charliteral">&#39;\0&#39;</span> };</div><div class="line"><a class="code" href="group__memorycapi.html#gad8eef9133e11fe77cd34792771f81761">memset</a>(ptr, <span class="charliteral">&#39;y&#39;</span>, 6 * <span class="keyword">sizeof</span>(<span class="keywordtype">char</span>));</div><div class="line"><a class="code" href="group__consolecapi.html#gaa99be0cc1b9e5cbbc2b12a43537e7ed3">prints</a>(ptr); <span class="comment">// Output: yyyyyy</span></div></div><!-- fragment --> 
</div>
</div>
<a id="ga87ed00a8f774a9d36d650b80a36ad932"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga87ed00a8f774a9d36d650b80a36ad932">&#9670;&nbsp;</a></span>sbrk()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void* sbrk </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__types.html#ga06896e8c53f721507066c079052171f8">uint32_t</a>&#160;</td>
          <td class="paramname"><em>num_bytes</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Allocate page(s) of memory to accommodate the requested number of bytes. </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">num_bytes</td><td>Number of bytes to add.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>void pointer to the previous end of allocated bytes</dd></dl>
<p>Example: </p><div class="fragment"><div class="line"><span class="comment">// allocate a whole new page, the returned offset is the pointer to the</span></div><div class="line"><span class="comment">// newly allocated page</span></div><div class="line"><span class="keywordtype">char</span>* new_page = <span class="keyword">static_cast&lt;</span><span class="keywordtype">char</span>*<span class="keyword">&gt;</span>(<a class="code" href="group__memorycapi.html#ga87ed00a8f774a9d36d650b80a36ad932">sbrk</a>(65536));</div><div class="line"><a class="code" href="group__memorycapi.html#gad8eef9133e11fe77cd34792771f81761">memset</a>(new_page, 0, 65536);</div></div><!-- fragment --> 
</div>
</div>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.13
</small></address>
</body>
</html>
